package com.ruoyi.labsafety.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labsafety.domain.LabSafetyCheckRelUser;
import com.ruoyi.labsafety.service.ILabSafetyCheckRelUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 安全检查人员Controller
 * 
 * @author ruoyi
 * @date 2022-03-30
 */
@RestController
@RequestMapping("/labsafety/user")
public class LabSafetyCheckRelUserController extends BaseController
{
    @Autowired
    private ILabSafetyCheckRelUserService labSafetyCheckRelUserService;

    /**
     * 查询安全检查人员列表
     */
   // @PreAuthorize("@ss.hasPermi('labsafety:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabSafetyCheckRelUser labSafetyCheckRelUser)
    {
        startPage();
        List<LabSafetyCheckRelUser> list = labSafetyCheckRelUserService.selectLabSafetyCheckRelUserList(labSafetyCheckRelUser);
        return getDataTable(list);
    }

    /**
     * 导出安全检查人员列表
     */
   // @PreAuthorize("@ss.hasPermi('labsafety:user:export')")
    @Log(title = "安全检查人员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabSafetyCheckRelUser labSafetyCheckRelUser)
    {
        List<LabSafetyCheckRelUser> list = labSafetyCheckRelUserService.selectLabSafetyCheckRelUserList(labSafetyCheckRelUser);
        ExcelUtil<LabSafetyCheckRelUser> util = new ExcelUtil<LabSafetyCheckRelUser>(LabSafetyCheckRelUser.class);
        return util.exportExcel(list, "user");
    }

    /**
     * 获取安全检查人员详细信息
     */
   // @PreAuthorize("@ss.hasPermi('labsafety:user:query')")
    @GetMapping(value = "/{safetyCheckRelUserId}")
    public AjaxResult getInfo(@PathVariable("safetyCheckRelUserId") Long safetyCheckRelUserId)
    {
        return AjaxResult.success(labSafetyCheckRelUserService.selectLabSafetyCheckRelUserById(safetyCheckRelUserId));
    }

    /**
     * 新增安全检查人员
     */
  //  @PreAuthorize("@ss.hasPermi('labsafety:user:add')")
    @Log(title = "安全检查人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabSafetyCheckRelUser labSafetyCheckRelUser)
    {
        return toAjax(labSafetyCheckRelUserService.insertLabSafetyCheckRelUser(labSafetyCheckRelUser));
    }

    /**
     * 修改安全检查人员
     */
  //  @PreAuthorize("@ss.hasPermi('labsafety:user:edit')")
    @Log(title = "安全检查人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabSafetyCheckRelUser labSafetyCheckRelUser)
    {
        return toAjax(labSafetyCheckRelUserService.updateLabSafetyCheckRelUser(labSafetyCheckRelUser));
    }

    /**
     * 删除安全检查人员
     */
  //  @PreAuthorize("@ss.hasPermi('labsafety:user:remove')")
    @Log(title = "安全检查人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{safetyCheckRelUserIds}")
    public AjaxResult remove(@PathVariable Long[] safetyCheckRelUserIds)
    {
        return toAjax(labSafetyCheckRelUserService.deleteLabSafetyCheckRelUserByIds(safetyCheckRelUserIds));
    }
}
